function signFunc(x) {
  if (x > 0) {
    return 1
  } else if (x < 0) {
    return -1
  } else {
    return 0
  }
}
/**
 * @param {number[]} nums
 * @return {number}
 */
export var arraySign = function (nums) {
  let ans = 1
  for (let i = 0; i < nums.length; i++) {
    ans *= nums[i]
    if (ans === 0) {
      return 0
    }
  }
  return signFunc(ans)
}

export var arraySign2 = function (nums) {
  const product = nums.reduce((pre, cur) => {
    return pre * cur
  })
  return signFunc(product)
}

/**
 * @param {number[]} nums
 * @return {number}
 */
export var arraySign3 = function (nums) {
  let ans = true
  for (let i = 0; i < nums.length; i++) {
    if (nums[i] === 0) return 0
    if (nums[i] < 0) ans = !ans
  }
  return ans ? 1 : -1
}
